package com.company;

import java.util.Scanner;

/**
 * @author jrue
 * @version 1.0
 * @date 2020/3/19 20:13
 */
public class Main18 {

    public static int solution(int[] data) {
        int[] dp = new int[data.length];
        dp[0] = 1;
        int max = 0;
        for (int i = 1; i < dp.length;i++) {
            if (data[i] >= data[i - 1]){
                dp[i] = dp[i - 1] + 1;
            } else {
                dp[i] = 1;
            }
            max = Math.max(max,dp[i]);
        }
        return max;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] data = new int[n];
        String s = sc.next();
        for (int i = 0; i < data.length; i++) {
            data[i] = s.charAt(i) - '0';
        }

        for (int i = 0; i < m; i++) {
            String s1 = sc.next();
            if (s1.equals("q")) {
                System.out.println(solution(data));
            } else {
                int start = sc.nextInt();
                int end = sc.nextInt();
                for (int j = start - 1; j < end; j++) {
                    if (data[j] == 0) data[j] = 1;
                    else data[j] = 0;
                }
            }
        }
    }

}
